﻿using Quartz;
using Quartz.Impl;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using WFAC360Sendmail.Job;

namespace WFAC360Sendmail
{
    public partial class SendmailForm : Form
    {
        public SendmailForm()
        {
            InitializeComponent();
        }

        private void btnStart_Click(object sender, System.EventArgs e)
        {
            IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
            scheduler.Start();

            IJobDetail jobSendmailCreateDao = JobBuilder.Create<ReturnResultCreateDaoRequest>().Build();

            ITrigger trigger = TriggerBuilder.Create()
                .WithDailyTimeIntervalSchedule
                  (s =>
                     s.WithIntervalInMinutes(5)
                    .OnEveryDay()
                    .StartingDailyAt(TimeOfDay.HourAndMinuteOfDay(15, 25))
                  )
                .Build();
            scheduler.ScheduleJob(jobSendmailCreateDao, trigger);
        }


        private void btnOff_Click(object sender, EventArgs e)
        {
            IScheduler scheduler = StdSchedulerFactory.GetDefaultScheduler();
            scheduler.Shutdown();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }
    }
}
